package com.scalpel.controller;

import com.jfinal.core.Controller;
import com.scalpel.util.word.ImageUtil;
import com.scalpel.util.word.WordUtil;
import freemarker.template.TemplateException;

import java.io.IOException;
import java.io.StringWriter;
import java.net.URL;
import java.util.HashMap;

/**
 * Created by scalpel on 2017/1/20.
 */
public class HelloController extends Controller {
    
    public void index() throws TemplateException {
        this.getResponse().setHeader("Content-disposition", "attachment; filename=test.doc");
        this.getResponse().setContentType("application/octet-stream");
        this.getResponse().setCharacterEncoding("utf-8");
        try {
            StringWriter writer = new StringWriter();
            WordUtil.createWordOutputByTemplate(new HashMap<String, Object>(),"test_export.xml",this.getResponse().getWriter());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
